package chabernac.android.wordbattle.paint.crosstile;

import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import chabernac.android.wordbattle.WordBattleView;
import chabernac.android.wordbattle.model.Letter;
import chabernac.android.wordbattle.model.Word;

public class QuarterUpRightCrossTileDrawable extends AbstractQuarterCrossTileDrawable {
	
	public QuarterUpRightCrossTileDrawable( Word aSelectedWord, Letter aUpRightLetter ) {
		super(aSelectedWord, aUpRightLetter);
	}
	
	@Override
	protected Bitmap getBitmap(WordBattleView aWordBattleView)
	{
		SvgResourceNameBuilder aBuilder = new SvgResourceNameBuilder();
		if(mySelectedWord.contains(myCornerLetter))
		{
			aBuilder.appendSelectStringUpRight();
		}
		return CrossTileBitmapFactory.getInstance().getCrossTileBitmap(aBuilder.getResourceName(), aWordBattleView);
	}
	
	@Override
	protected Point getDrawingPoint(WordBattleView aWordBattleView) {
		int x = WordBattleView.BORDER_SIZE;
		int y = WordBattleView.BORDER_SIZE;
		// Horizontal left and vertical center of upper left right
		x += (int)(myCornerLetter.getColumn() * aWordBattleView.getWidthPerColumn());
		y += (int)(myCornerLetter.getRow() * aWordBattleView.getHeightPerRow());
		y += (int)(aWordBattleView.getHeightPerRow()/2);
		return new Point(x,y);
	}
	
	@Override
	protected Rect getBitmapSubsetRect(Bitmap aBitmap) {
		return new Rect((int)aBitmap.getWidth()/2,0,(int)aBitmap.getWidth(), (int)aBitmap.getHeight()/2);
	}
}
